<?php
include "../../../lib/list.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<link rel="stylesheet" href="../../../css/list.css" type="text/css"></link>
<link rel="stylesheet" href="../../../css/table.blue.sorter.css"
	type="text/css" media="print, projection, screen"></link>
<link rel="stylesheet" href="../../../css/jquery.tablesorter.pager.css"
	type="text/css" media="print, projection, screen"></link>
<script type="text/javascript" src="../../../js/jquery-1.2.6.js"></script>
<script type="text/javascript"
	src="../../../js/jquery.tablesorter.pager.js"></script>
<script type="text/javascript" src="../../../js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="../../../js/list.js"></script>
<script type="text/javascript">
	$(function(){
		$("table")
			.tablesorter({headers: {             
     		   		0: {               
        		     // 정렬선택 안함
        		     sorter: false         
        		    },            
        		    4: {              
        		     sorter: false          
        		    }         
        		   }, widthFixed: true, widgets: ['zebra'] })
			.tablesorterPager({container: $("#pager")});
	});
	function movepage(url,get,value){
		location.href = url+"?"+get+"="+value;
	}
	</script>
</head>
<body>
	<div style="width: 1024px; padding: 10px;">
		<div
			style="border-bottom: 1px solid #e8e8e8; text-align: left; font-size: 12px; margin-bottom: 12px; color: #9a9a9a">:::
			마스터 관리&nbsp;⇒&nbsp;점포그룹마스터</div>
		<div style="float: right; padding: 5px;">
			<input type="button" class="button red small" value="삭제하기" onclick="javascript:list_delete();" /> 
			<input type="button" class="button green small" value="수정하기" onclick="javascript:list_modify();" /> 
			<input type="button" class="button white small" value="입력하기" onclick="javascript:location.href='insert.php'" />
		</div>
		<form name="view" method="post" enctype=multipart/form-data
			action="insert.php">
			<input type="hidden" value="" name="mode" />
			<table cellspacing="1" class="tablesorter">
				<thead>
					<tr>
						<th width="10px"><input
							onclick="if (this.checked) all_checked(true); else all_checked(false);"
							type=checkbox tabindex=1 name=chk_head />
						</th>
						<th>no</th>
						<th>그룹 명</th>
						<th>점포갯수</th>
						<th>비고</th>
						<th>책임자</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<th width="10px">&nbsp;</th>
						<th>no</th>
						<th>그룹 명</th>
						<th>점포갯수</th>
						<th>비고</th>
						<th>책임자</th>
					</tr>
				</tfoot>
				<tbody>
				<?php
				$query = "select * from uatp_shopgroup where no != -1 and no != -2 order by no DESC ";
				$total = DBnumrows($query);
				$result = DBquery($query);

				for($i=1; $list = mysql_fetch_array($result); $i++){
					$bunho = $total - ( $i + $cline) + 1;
					$qry = "SELECT * FROM `uatp_staff` WHERE `sg_no` = $list[no] AND `lv` = '2'";
					$manager = DBarray($qry);
					?>
					<tr onclick="javascript:chk(<?=$list[no]?>)">
						<td><input type=checkbox name=chk_no[] value="<?=$list['no']?>"
							onclick="javascript:chk(<?=$list['no']?>)"></input></td>
						<td align="center" width="30px"><?=$bunho?></td>
						<td><b><?=$list['name']?> </b></td>
						<td <?=$MouseOver?>
							onclick="javascript:movepage('../shop/view.php','sg_no','<?=$list['no']?>');"><?
							$sql = "select * from uatp_shopinfo where sg_no = ".$list['no']." order by no DESC";
							echo DBnumrows($sql);
							?>
						</td>
						<td><?=$list['note']?></td>
						<?if(!$manager){
							echo "<td $MouseOver onclick=javascript:movepage('../staff/view.php','sg_no','$list[no]');><font color='#B4045F'>책임자를 선택해주세요.</font></td>";
							}
							else{ echo "<td $MouseOver onclick=javascript:movepage('../staff/detail.php','no','$manager[no]');><font color='black'>$manager[name]</font></td>";
							}?>
					</tr>					
<?php 
}
	mysql_free_result($result);
?>
					<tr>
						<td width="10px">&nbsp;</td>
						<td>&nbsp;</td>
						<td><center>삭제된 점포</center></td>
						<td <?=$MouseOver?>
							onclick="javascript:movepage('../shop/view.php','sg_no','-1');"><?
							$sql = "select * from uatp_shopinfo where sg_no = -1 order by no DESC";
							echo DBnumrows($sql);
							?>
						</td>
						<td align=center><b>문닫은 점포들입니다.</b></td>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td width="10px">&nbsp;</td>
						<td>&nbsp;</td>
						<td><center>그룹없음</center></td>
						<td <?=$MouseOver?>
							onclick="javascript:movepage('../shop/view.php','sg_no','-2');"><?
							$sql = "select * from uatp_shopinfo where sg_no = -2 order by no DESC";
							echo DBnumrows($sql);
							?>
						</td>
						<td align=center><b>그룹에 포함되지 않은 점포들입니다.</b></td>
						<td>&nbsp;</td>
					</tr>
			</tbody>
			</table>
		</form>

		<div id="pager" class="pager">
			<form>
				<img src="../../../image/first.png" class="first" /> <img
					src="../../../image/prev.png" class="prev" /> <input type="text"
					class="pagedisplay" /> <img src="../../../image/next.png"
					class="next" /> <img src="../../../image/last.png" class="last" />
				<select class="pagesize">
					<option selected="selected" value="10">10</option>
					<option value="20">20</option>
					<option value="30">30</option>
					<option value="40">40</option>
				</select>
			</form>
		</div>

	</div>
</body>
</html>
